<?php
/**
 * 自定义WordPress登录和注册页面
 * 直接在函数中生成HTML，不再依赖login.html
 */
function wanzicms_custom_login_page()
{
    // 如果是POST请求，让WordPress核心处理登录/注册/密码重置等操作
    if ('POST' === $_SERVER['REQUEST_METHOD']) {
        return;
    }

    $action = isset($_GET['action']) ? $_GET['action'] : 'login';

    // 站点头部HTML
    ob_start();
?>
    <header id="navbar" class="fixed w-full top-0 z-50 transition-all duration-300 bg-white/95 shadow-sm">
        <div class="container mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between items-center h-16">
                <!-- Logo -->
                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="flex items-center">
                    <img src="<?php echo get_template_directory_uri(); ?>/assets/img/logo.png" alt="<?php bloginfo('name'); ?>" class="h-10 w-auto">
                    <span class="text-xl ml-2 font-bold text-neutral-800">丸子资讯</span>
                </a>

                <!-- 导航链接 - 桌面端 -->
                <nav class="hidden md:flex space-x-8">
                    <?php
                    wp_nav_menu(array(
                        'theme_location' => 'primary',
                        'menu_class' => 'flex space-x-8 group',
                        'container' => false,
                        'depth' => 2,
                        'walker' => new Walker_Nav_Menu(),
                        'items_wrap' => '<ul class="%2$s">%3$s</ul>',
                        'fallback_cb' => false
                    ));
                    ?>
                </nav>

                <!-- 右侧操作区 -->
                <div class="flex items-center space-x-4">
                    <button class="search-btn p-2 rounded-full hover:bg-neutral-100 transition-colors relative">
                        <i class="fa fa-search text-neutral-600"></i>
                    </button>
                    <button class="hidden sm:block p-2 rounded-full hover:bg-neutral-100 transition-colors relative">
                        <i class="fa fa-bell text-neutral-600"></i>
                        <span class="absolute top-1 right-1 h-2 w-2 rounded-full bg-red-500"></span>
                    </button>
                    <a href="<?php echo wp_login_url(); ?>" class="hidden sm:flex items-center space-x-2 px-4 py-2 rounded-full bg-primary text-white hover:bg-primary/90 transition-colors">
                        <i class="fa fa-user-circle-o"></i>
                        <span>登录</span>
                    </a>

                    <!-- 移动端菜单按钮 -->
                    <button id="mobile-menu-button" class="md:hidden p-2 rounded-md text-neutral-600 hover:text-primary hover:bg-neutral-100 focus:outline-none">
                        <i class="fa fa-bars text-xl"></i>
                    </button>
                </div>
            </div>
        </div>

        <!-- 移动端菜单 -->
        <div id="mobile-menu" class="md:hidden hidden bg-white border-t border-neutral-200">
            <div class="px-4 py-3 space-y-3">
                <?php
                wp_nav_menu(array('theme_location' => 'primary', 'menu_class' => 'space-y-3', 'container' => false));
                ?>
                <div class="pt-2 border-t border-neutral-200">
                    <a href="<?php echo wp_login_url(); ?>" class="w-full flex items-center justify-center space-x-2 px-4 py-2 rounded-full bg-primary text-white hover:bg-primary/90 transition-colors">
                        <i class="fa fa-user-circle-o"></i>
                        <span>登录/注册</span>
                    </a>
                </div>
            </div>
        </div>
    </header>
<?php
    $site_header = ob_get_clean();

    // 搜索模态框HTML
    ob_start();
?>
    <div id="search-modal">
        <div class="modal-content">
            <button id="close-search-modal" class="close-button">×</button>
            <input type="text" class="search-box" placeholder="输入搜索内容...">
            <div id="search-results"></div>
        </div>
    </div>
<?php
    $search_modal_html = ob_get_clean();

    // 根据action生成不同的表单
    $form_html = '';
    $page_title_text = '';
    $form_header_title = '';
    $form_header_subtitle = '';
    $switch_link_html = '';

    if ('register' === $action) {
        if (!get_option('users_can_register')) {
            $form_html = '<div class="text-center p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50" role="alert">抱歉，当前站点已关闭新用户注册。</div>';
            $page_title_text = get_bloginfo('name') . ' - 注册已关闭';
            $form_header_title = '注册已关闭';
            $switch_link_html = '<a href="' . esc_url(wp_login_url()) . '" class="font-medium text-primary hover:text-primary/80 transition-colors">返回登录</a>';
        } else {
            $page_title_text = get_bloginfo('name') . ' - 注册';
            $form_header_title = '创建您的账户';
            $form_header_subtitle = '加入' . get_bloginfo('name') . '，开始您的分享之旅';
            $switch_link_html = '已有账户？ <a href="' . esc_url(wp_login_url()) . '" class="font-medium text-primary hover:text-primary/80 transition-colors">立即登录</a>';

            ob_start();
?>
            <form name="registerform" id="registerform" action="<?php echo esc_url(site_url('wp-login.php?action=register', 'login_post')); ?>" method="post" class="space-y-6" novalidate="novalidate">
                <div>
                    <label for="user_login" class="block text-sm font-medium text-neutral-700 mb-1">用户名</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa fa-user text-neutral-400"></i>
                        </div>
                        <input type="text" name="user_login" id="user_login" class="block w-full pl-10 pr-3 py-3 border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-colors" placeholder="请输入用户名" required>
                    </div>
                </div>

                <div>
                    <label for="user_email" class="block text-sm font-medium text-neutral-700 mb-1">电子邮箱</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa fa-envelope text-neutral-400"></i>
                        </div>
                        <input type="email" name="user_email" id="user_email" class="block w-full pl-10 pr-3 py-3 border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-colors" placeholder="请输入电子邮箱" required>
                    </div>
                </div>

                <?php do_action('register_form'); ?>

                <p class="text-xs text-neutral-500">
                    一封确认邮件将发送到您的邮箱。
                </p>

                <button type="submit" name="wp-submit" id="wp-submit" class="w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors">
                    注册
                </button>
            </form>
        <?php
            $form_html = ob_get_clean();
        }
    } else { // 'login' and other actions
        $page_title_text = get_bloginfo('name') . ' - 登录';
        $form_header_title = '登录您的账户';
        $form_header_subtitle = '欢迎回来，请使用您的用户名和密码登录继续浏览' . get_bloginfo('name');
        $switch_link_html = '还没有账户？ <a href="' . esc_url(wp_registration_url()) . '" class="font-medium text-primary hover:text-primary/80 transition-colors">立即注册</a>';

        ob_start();
        ?>
            <form name="loginform" id="loginform" action="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?>" method="post" class="space-y-6">
                <div>
                    <label for="user_login" class="block text-sm font-medium text-neutral-700 mb-1">用户名</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa fa-user text-neutral-400"></i>
                        </div>
                        <input type="text" name="log" id="user_login" class="block w-full pl-10 pr-3 py-3 border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-colors" placeholder="请输入用户名" required>
                    </div>
                </div>

                <div>
                    <div class="flex justify-between items-center mb-1">
                        <label for="user_pass" class="block text-sm font-medium text-neutral-700">密码</label>
                        <a href="<?php echo esc_url(wp_lostpassword_url()); ?>" class="text-sm text-primary hover:text-primary/80 transition-colors">忘记密码？</a>
                    </div>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa fa-lock text-neutral-400"></i>
                        </div>
                        <input type="password" name="pwd" id="user_pass" class="block w-full pl-10 pr-3 py-3 border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-colors" placeholder="请输入密码" required>
                        <button type="button" id="toggle-password" class="absolute inset-y-0 right-0 pr-3 flex items-center text-neutral-400 hover:text-neutral-600">
                            <i class="fa fa-eye-slash"></i>
                        </button>
                    </div>
                </div>

                <div class="flex items-center">
                    <input id="rememberme" name="rememberme" type="checkbox" value="forever" class="h-4 w-4 text-primary focus:ring-primary border-neutral-300 rounded">
                    <label for="rememberme" class="ml-2 block text-sm text-neutral-600">记住我的登录状态</label>
                </div>

                <button type="submit" name="wp-submit" id="wp-submit" class="w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors">
                    登录
                </button>

                <input type="hidden" name="redirect_to" value="<?php echo esc_url(admin_url()); ?>">
                <input type="hidden" name="testcookie" value="1">
            </form>
    <?php
        $form_html = ob_get_clean();
    }

    // 自定义CSS
    ob_start();
?>
    <style>
        /* 主题颜色变量 */
        :root {
            --primary-color: #165DFF;
            --primary-hover: rgba(22, 93, 255, 0.9);
            --neutral-100: #F9FAFB;
            --neutral-200: #F3F4F6;
            --neutral-300: #E5E7EB;
            --neutral-400: #D1D5DB;
            --neutral-500: #9CA3AF;
            --neutral-600: #6B7280;
            --neutral-700: #4B5563;
            --neutral-800: #1F2937;
            --neutral-900: #111827;
        }

        html,
        body {
            height: 100%;
        }

        body {
            background-color: #f9fafb;
            display: flex;
            flex-direction: column;
        }

        /* 调整页面上边距，使表单位置更合理 */
        .login-page-container {
            padding-top: 7rem;
            flex-grow: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding-bottom: 3rem;
        }

        .login-card {
            width: 100%;
            max-width: 450px;
            background-color: #fff;
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), 0 4px 10px rgba(0, 0, 0, 0.02);
            overflow: hidden;
        }

        /* 确保登录表单正确显示 */
        .login-form-container {
            padding: 2.5rem;
        }

        @media (min-width: 1024px) {
            .login-form-container {
                padding: 3rem;
            }
        }

        /* 搜索模态框样式 */
        #search-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 9999;
            animation: fadeIn 0.3s ease-in-out;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        #search-modal .modal-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: linear-gradient(135deg, #f9fbfc 0%, #ffffff 100%);
            width: 80%;
            max-width: 650px;
            padding: 40px;
            border-radius: 16px;
            box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
            animation: slideIn 0.3s ease-in-out;
            overflow: hidden;
        }

        @keyframes slideIn {
            from {
                top: 45%;
                opacity: 0;
            }

            to {
                top: 50%;
                opacity: 1;
            }
        }

        #search-modal .search-box {
            width: 100%;
            padding: 16px 20px;
            font-size: 18px;
            border: 2px solid #e0e6ed;
            border-radius: 8px;
            outline: none;
            transition: all 0.3s ease;
            background-color: #f8f9fa;
            color: #32325d;
        }

        #search-modal .search-box:focus {
            border-color: #6772e5;
            box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
            background-color: #ffffff;
        }

        #search-modal .close-button {
            position: absolute;
            top: 15px;
            right: 15px;
            background: none;
            border: none;
            font-size: 28px;
            color: #8898aa;
            cursor: pointer;
            transition: all 0.2s ease;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
        }

        #search-modal .close-button:hover {
            color: #32325d;
            background-color: #f0f4f8;
        }

        #search-results {
            margin-top: 25px;
            max-height: 350px;
            overflow-y: auto;
            border-top: 2px solid #f0f4f8;
            padding-top: 20px;
        }

        /* 子菜单样式 */
        .sub-menu {
            visibility: hidden;
            position: absolute;
            top: calc(100% + 1px);
            transition: all 0.3s ease, visibility 0.3s;
            opacity: 0;
            left: 10px;
            min-width: 200px;
            background-color: #fff;
            padding: 0;
            border-radius: 0.375rem;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            z-index: 1000;
        }

        .menu-item-has-children:hover>.sub-menu {
            visibility: visible;
            opacity: 1;
        }

        .menu-item-has-children {
            position: relative;
        }

        @media (max-width: 768px) {
            .sub-menu {
                position: static;
                box-shadow: none;
                padding-left: 1rem;
                min-width: auto;
                visibility: hidden;
                opacity: 1;
                transition: all 0.3s ease, visibility 0.3s;
            }

            .menu-item-has-children:hover > .sub-menu {
                visibility: hidden;
            }

            .menu-item-has-children.active > .sub-menu {
                visibility: visible;
            }
        }

        .sub-menu .sub-menu {
            left: 100%;
            top: 0;
        }

        .sub-menu li {
            padding: 0.5rem 1rem;
            transition: all 0.2s ease;
        }

        .sub-menu li:hover {
            background-color: #f3f4f6;
            transform: translateX(5px);
        }

        .sub-menu a {
            color: #374151;
            white-space: nowrap;
        }

        .current-menu-item > a,
        .current-menu-parent > a {
            color: var(--primary-color);
        }

        /* 修复Tailwind类 */
        .bg-primary {
            background-color: var(--primary-color);
        }

        .hover\:bg-primary\/90:hover {
            background-color: var(--primary-hover);
        }

        .text-primary {
            color: var(--primary-color);
        }

        .hover\:text-primary:hover {
            color: var(--primary-color);
        }

        .hover\:text-primary\/80:hover {
            color: rgba(22, 93, 255, 0.8);
        }

        .focus\:ring-primary:focus {
            --tw-ring-color: var(--primary-color);
        }

        .focus\:ring-primary\/50:focus {
            --tw-ring-color: rgba(22, 93, 255, 0.5);
        }

        .focus\:border-primary:focus {
            border-color: var(--primary-color);
        }

        .bg-gradient-primary {
            background: linear-gradient(135deg, #165DFF 0%, #0A36B1 100%);
        }

        /* 空间类 */
        .space-y-6 > * + * {
            margin-top: 1.5rem;
        }

        .mt-6 {
            margin-top: 1.5rem;
        }

        .mt-8 {
            margin-top: 2rem;
        }

        .mb-6 {
            margin-bottom: 1.5rem;
        }

        .mb-8 {
            margin-bottom: 2rem;
        }

        .mb-1 {
            margin-bottom: 0.25rem;
        }

        .mr-2 {
            margin-right: 0.5rem;
        }

        .ml-2 {
            margin-left: 0.5rem;
        }

        .gap-4 {
            gap: 1rem;
        }

        .grid-cols-3 {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }
    </style>
<?php
    $custom_css = ob_get_clean();

    // 自定义JavaScript
    ob_start();
?>
    <script>
        document.addEventListener("DOMContentLoaded", function() {
            // 处理密码显示/隐藏切换
            var togglePassword = document.getElementById("toggle-password");
            var passwordInput = document.getElementById("user_pass");

            if (togglePassword && passwordInput) {
                togglePassword.addEventListener("click", function() {
                    var type = passwordInput.getAttribute("type") === "password" ? "text" : "password";
                    passwordInput.setAttribute("type", type);

                    // 切换图标
                    var icon = togglePassword.querySelector("i");
                    if (type === "text") {
                        icon.classList.remove("fa-eye-slash");
                        icon.classList.add("fa-eye");
                    } else {
                        icon.classList.remove("fa-eye");
                        icon.classList.add("fa-eye-slash");
                    }
                });
            }

            // 移动端菜单切换
            var mobileMenuButton = document.getElementById("mobile-menu-button");
            var mobileMenu = document.getElementById("mobile-menu");

            if (mobileMenuButton && mobileMenu) {
                mobileMenuButton.addEventListener("click", function() {
                    if (mobileMenu.classList.contains("hidden")) {
                        mobileMenu.classList.remove("hidden");
                    } else {
                        mobileMenu.classList.add("hidden");
                    }
                });
            }

            // 为移动端菜单中的二级菜单添加交互
            var subMenus = document.querySelectorAll("#mobile-menu .sub-menu");
            subMenus.forEach(function(menu) {
                menu.style.display = "none";
                var parentLink = menu.previousElementSibling;
                if (parentLink.tagName === 'A') {
                    parentLink.addEventListener("click", function(e) {
                        e.preventDefault();
                        var subMenu = this.nextElementSibling;
                        if (subMenu.style.display === "none") {
                            subMenu.style.display = "block";
                            this.parentElement.classList.add('active');
                        } else {
                            subMenu.style.display = "none";
                            this.parentElement.classList.remove('active');
                        }
                    });
                }
            });

            // 搜索功能
            var searchButtons = document.querySelectorAll(".search-btn");
            searchButtons.forEach(function(button) {
                button.addEventListener("click", function() {
                    var searchModal = document.getElementById("search-modal");
                    if (searchModal) {
                        searchModal.style.display = "block";
                        document.querySelector("#search-modal .search-box").focus();
                    }
                });
            });

            var closeSearchButton = document.getElementById("close-search-modal");
            if (closeSearchButton) {
                closeSearchButton.addEventListener("click", function() {
                    document.getElementById("search-modal").style.display = "none";
                });
            }

            // 点击模态框背景关闭
            var searchModal = document.getElementById("search-modal");
            if (searchModal) {
                searchModal.addEventListener("click", function(e) {
                    if (e.target === this) {
                        this.style.display = "none";
                    }
                });
            }

            // 处理搜索请求
            var searchBox = document.querySelector("#search-modal .search-box");
            var searchResults = document.getElementById("search-results");
            var searchTimeout;

            if (searchBox && searchResults) {
                searchBox.addEventListener("input", function() {
                    clearTimeout(searchTimeout);
                    var query = this.value.trim();

                    if (query.length > 2) {
                        searchTimeout = setTimeout(function() {
                            searchResults.innerHTML = "<p class='text-center py-4'>正在搜索...</p>";

                            fetch("<?php echo admin_url('admin-ajax.php'); ?>?action=wanzicms_search&s=" + encodeURIComponent(query))
                                .then(response => response.json())
                                .then(data => {
                                    if (data.length > 0) {
                                        var resultsHtml = "";
                                        data.forEach(function(item) {
                                            resultsHtml += "<div class='result-item p-4 hover:bg-gray-50 rounded transition-all'>";
                                            resultsHtml += "<a href='" + item.link + "' class='result-title block font-medium text-primary mb-1'>" + item.title + "</a>";
                                            resultsHtml += "<div class='result-excerpt text-sm text-gray-600'>" + item.excerpt + "</div>";
                                            resultsHtml += "</div>";
                                        });
                                        searchResults.innerHTML = resultsHtml;
                                    } else {
                                        searchResults.innerHTML = "<p class='text-center py-4 text-gray-500'>没有找到相关结果</p>";
                                    }
                                })
                                .catch(error => {
                                    searchResults.innerHTML = "<p class='text-center py-4 text-red-500'>搜索出错，请重试</p>";
                                    console.error("搜索错误:", error);
                                });
                        }, 500);
                    } else if (query.length === 0) {
                        searchResults.innerHTML = "";
                    }
                });
            }
        });
    </script>
<?php
    $custom_js = ob_get_clean();

?>
    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>

    <head>
        <meta charset="<?php bloginfo('charset'); ?>">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title><?php echo $page_title_text; ?></title>
        <script src="<?php echo get_template_directory_uri(); ?>/assets/js/tailwindcss.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/assets/js/tailwind-config.js"></script>
        <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/assets/css/font-awesome.min.css">
        <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/assets/css/custom.css">
        <?php echo $custom_css; ?>
        <?php do_action('login_head'); ?>
    </head>

    <body class="login">
        <?php echo $site_header; ?>
        <?php echo $search_modal_html; ?>

        <main class="login-page-container">
            <div class="login-wrapper lg:grid lg:grid-cols-2 lg:gap-12 xl:gap-24 w-full max-w-6xl mx-auto px-4">
                <div class="hidden lg:block text-white text-center h-full">
                    <div class="bg-gradient-primary rounded-2xl p-12 h-full flex flex-col justify-center">
                        <h2 class="text-3xl font-bold mb-4">欢迎来到<?php echo get_bloginfo('name'); ?></h2>
                        <p class="text-white/80 mb-12">一个充满活力的资讯分享与交流社区</p>
                        <div class="space-y-6 w-full max-w-md mx-auto">
                            <div class="flex items-center space-x-4">
                                <div class="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center">
                                    <i class="fa fa-globe text-white"></i>
                                </div>
                                <div class="text-left">
                                    <h3 class="font-medium">全球资讯</h3>
                                    <p class="text-white/80 text-sm">及时了解世界各地发生的重要事件</p>
                                </div>
                            </div>
                            <div class="flex items-center space-x-4">
                                <div class="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center">
                                    <i class="fa fa-lightbulb-o text-white"></i>
                                </div>
                                <div class="text-left">
                                    <h3 class="font-medium">专业分析</h3>
                                    <p class="text-white/80 text-sm">获取行业专家对热点问题的深度解读</p>
                                </div>
                            </div>
                            <div class="flex items-center space-x-4">
                                <div class="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center">
                                    <i class="fa fa-bookmark-o text-white"></i>
                                </div>
                                <div class="text-left">
                                    <h3 class="font-medium">个性化内容</h3>
                                    <p class="text-white/80 text-sm">根据您的兴趣定制专属阅读内容</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="login-card h-full flex flex-col justify-center">
                    <div class="login-form-container">
                        <div class="login-form-header">
                            <h2 class="text-2xl font-bold text-neutral-800 mb-6"><?php echo $form_header_title; ?></h2>
                            <?php if (!empty($form_header_subtitle)) : ?>
                                <p class="text-neutral-600 mb-8"><?php echo $form_header_subtitle; ?></p>
                            <?php endif; ?>
                        </div>
                        <?php echo $form_html; ?>
                        <p class="login-register-link mt-8 text-center text-sm text-neutral-600">
                            <?php echo $switch_link_html; ?>
                        </p>
                    </div>
                </div>
            </div>
        </main>

        <?php echo $custom_js; ?>
        <?php do_action('login_footer'); ?>
    </body>

    </html>
<?php
    exit;
}
add_action('login_init', 'wanzicms_custom_login_page');

// 修改登录页面的链接和文字
function wanzicms_login_headerurl()
{
    return home_url();
}
add_filter('login_headerurl', 'wanzicms_login_headerurl');

function wanzicms_login_headertext()
{
    return get_bloginfo('name');
}
add_filter('login_headertext', 'wanzicms_login_headertext');

// 自定义登录页面的标题
function wanzicms_login_title()
{
    return get_bloginfo('name') . ' - 登录';
}
add_filter('login_title', 'wanzicms_login_title');